/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package commands;

import IA.InformationAggregator;
import IA.Service;
/**
 *
 * @author Jeremy
 */
public class CmdStartNewService extends Command {
    private int nc; private int TableID; private int ServerID; int et;
    public CmdStartNewService(InformationAggregator ia, int NumCustomers, int TableID, int EatTime) {
        super(ia);
        nc = NumCustomers; this.TableID = TableID;
        et = EatTime;
    }
    
    @Override
    public java.lang.Object execute() {
        if(ia.getServerCollection().getNumServers() == 0) {
            System.out.println("Cannot add service.  No Servers.");
            return null;
        }
        ServerID = ia.getServerCollection().getShortestWorkloadServerItr().next().getID();
        System.out.println("Customer @ Table " + TableID + ", Server " + ServerID);
        Service s = ia.getServiceCollection().AddService(nc, TableID, ServerID, et);
        ia.getServerCollection().getServer(ServerID).assignToTable(TableID, s);
        ia.getTableCollection().assignTable(TableID, false);
        return null;
    }
}
